<template>
	<view>
		
		<!-- 身份为参与方  -->  
		<!-- 参与方收到 发布方 申请 的售后 ， 觉得不对  提交申诉表单 给 发布方后 ， 发布方不同意 但修改了自己的申请操作 显示结果 页面 -->
		
		<view v-if="is_cooperateAppeal_bool3==true">
			<block v-if="is_shensu==1">
				
				<orderCommon
					:text="text" :order="order" :afterSalesRecord="afterSalesRecord3" :is_time="false" :is_chat="true"
					:customStyle1="customStyle1" :customStyle11="customStyle11" 
					:customStyle2="customStyle2" :customStyle3="customStyle3">
				</orderCommon>
				
				<view class="cardBox" style="margin-top: 10rpx;">
					<view  style="margin-top: 10rpx;padding-bottom: 20rpx;">
						<image :src="IMAGE_URL+order.join_user.avatar" class="close_image2"></image>
						<view style="line-height: 140rpx;float: left;">
							<block v-if="lang==='zh'">{{order.join_user.username}}</block>
							<block v-if="lang==='ru'">{{order.join_user.username_ru}}</block>
						</view>
						
						<view style="clear: both;"></view>
						<view style="font-size:28rpx;padding-top: 10rpx;">{{text.burenke}} </view>
						
						<view class="flex" style="margin-top: 10rpx;padding-bottom: 20rpx;color: #999;">
							<view style="width: 50%;float: left; text-align: left;" >
								{{timestampToDate(afterSalesRecord.appeal_time*1000)}}
								
							</view>
						</view>
						<view style="clear: both;"></view>
							
					</view>
				</view>
				
				<appealCommon  @change = "shensu" @change3="customer"
					:text="text" :order="order" :afterSalesRecord="afterSalesRecord3" 
					:customStyle1="customStyle1" :customStyle11="customStyle11" 
					:customStyle2="customStyle2" :customStyle3="customStyle3">
				</appealCommon>
				

				
			</block>
		</view>
		
		
		
		<view v-if="is_cooperateAppeal_bool3==false">
			<block v-if="is_shensu==1">
				<orderCommon
					:text="text" :order="order" :afterSalesRecord="afterSalesRecord3" :is_time="false" :is_chat="true"
					:customStyle1="customStyle1" :customStyle11="customStyle11" 
					:customStyle2="customStyle2" :customStyle3="customStyle3">
				</orderCommon>
				
				<view class="cardBox" style="margin-top: 10rpx;">
					<view  style="margin-top: 10rpx;padding-bottom: 20rpx;">
						<image :src="IMAGE_URL+order.join_user.avatar" class="close_image2"></image>
						<view style="line-height: 140rpx;float: left;">
							<block v-if="lang==='zh'">{{order.join_user.username}}</block>
							<block v-if="lang==='ru'">{{order.join_user.username_ru}}</block>
						</view>
						
						<view style="clear: both;"></view>
						<view style="font-size:28rpx;padding-top: 10rpx;">{{text.burenke}} </view>
						
						<view class="flex" style="margin-top: 10rpx;padding-bottom: 20rpx;color: #999;">
							<view style="width: 50%;float: left; text-align: left;" >
								{{timestampToDate(afterSalesRecord.appeal_time*1000)}}
								
							</view>
						</view>
						<view style="clear: both;"></view>
							
					</view>
				</view>
				
				<appealCommon @change = "shensu" @change3="customer"
					:text="text" :order="order" :afterSalesRecord="afterSalesRecord3" 
					:customStyle1="customStyle1" :customStyle11="customStyle11" 
					:customStyle2="customStyle2" :customStyle3="customStyle3">
				</appealCommon>
				
				
			</block>
		</view>
		
		
		<block v-if="is_shensu==2">
			<cooperateApply v-if="loading" :text="text" :order="order" :customStyle1="customStyle1" :customStyle11="customStyle11" 
			:customStyle2="customStyle2" :afterSalesRecord="afterSalesRecord2" :customStyle3="customStyle3" @change="shensu_action">
			</cooperateApply>
		</block>
		
			
		<view style="height: 5px;"></view>
	
	</view>
</template>


<script>
	import {HTTP_REQUEST_URL,HTTP_IMG_UTL,IMAGE_URL} from "@/config/app";
	import orderCommon from './orderCommon.vue';
	import appealCommon from './appealCommon.vue';
	import cooperateApply from './cooperateApply.vue';
	import {
		ImageUrl,
		isVideo,
		time,createC2CConversation
	} from "@/common/public";
	export default {
		components:{
			orderCommon,appealCommon,cooperateApply
		},
		props:{
			order:{
				type:Object,
				default:{}
			},
			afterSalesRecord:{
				type:Object,
				default:{}
			},
			text:{
				type:Object,
				default:{}
			},
			customStyle1:{
				type:Object,
				default:{}
			},
			customStyle11:{
				type:Object,
				default:{}
			},
			customStyle2:{
				type:Object,
				default:{}
			},
			customStyle3:{
				type:Object,
				default:{}
			},
			is_cooperateAppeal_bool3:{
				type:Boolean,
				default:false
			}
		},
		data() {
			return {
				//远程域名
				HTTP_IMG_UTL,
				HTTP_REQUEST_URL,
				IMAGE_URL,
				url: IMAGE_URL,
				
				//语言
				lang: this.$i18n.locale,
				
				img:HTTP_IMG_UTL+'huangjin.png',
				subDisabled:false,
				
				release_do_time:'',
				
				is_shensu:1,
				
				loading:false,
				afterSalesRecord2:{},
				afterSalesRecord3:{}
			}
		},
		mounted() {
			this.release_do_time = this.afterSalesRecord.release_do_time
			this.afterSalesRecord3=this.afterSalesRecord
		},
		methods:{
			timestampToDate(timestamp) {
			  const date = new Date(timestamp); // 如果timestamp是数值，可以直接作为Date构造函数的参数
			  const year = date.getFullYear();
			  const month = (date.getMonth() + 1).toString().padStart(2, '0');
			  const day = date.getDate().toString().padStart(2, '0');
			  const hours = date.getHours().toString().padStart(2, '0');
			  const minutes = date.getMinutes().toString().padStart(2, '0');
			  const seconds = date.getSeconds().toString().padStart(2, '0');
			  return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
			},
			pingtai(){
				if(this.lang==='zh'){
					createC2CConversation(getApp().globalData.site.im_customer001, this,true)
				}else{
					createC2CConversation(getApp().globalData.site.im_customer002, this,true)
				}
			},
			shensu(){
				console.log(123)
				var that = this
				that.loading = false
				that.$u.api.order.afterSalesRecord({
					aftersales_id: that.order.orderInfo.aftersales_id,
					lang:that.lang
				}).then(result => {
					that.afterSalesRecord2 = result
					that.is_shensu=2
					that.loading = true
				})
			},
			shensu_action(e,data,res){
				var that = this
				console.log(res)
				that.afterSalesRecord3 = res
				that.is_shensu=1
			},
			approve(join_status){
				const that = this
				var json = {
					join_status: join_status,
					aftersales_id :that.order.orderInfo.aftersales_id,
					lang:that.lang
				}
				that.$u.api.order.approveAppeal(json).then(res => {
					uni.showModal({
						content: that.$t('操作成功'),
						showCancel: false,
						confirmText: this.$t('是'),
					})
					
					if(join_status==1){
						that.$emit('change','customer','approve')
					}
				})
			},
			customer(){
				this.$emit('change','customer','approve')
			}
		}
	}
</script>

<style lang="scss" scoped>
	.cardBox {
		width: 94%;
		margin: 0 auto;
		margin-top: 30rpx;
		box-shadow: 0 0 10px #ddd;
		background: #ddd;
		padding: 10rpx 20rpx;
		border-radius: 20rpx;
		background: #fff;
		margin-bottom: 30rpx;
		position: relative;
	}
	.flex{width: 100%;display: flex;}
	.biao{margin-top: 0rpx; width: 80%; margin-left: 0rpx;font-size: 30rpx;  font-weight: bold;}
	.biao_span{color:darkorange ; font-size: 18px; margin-right: 5px;}
	.cardTitle{font-size: 24rpx; width: 94%;padding-top: 6rpx;}
	.order_img{width: 160rpx;height: 160rpx;border-radius: 20rpx;}
	.close_image2{
		width: 120rpx;height: 120rpx;border-radius: 20rpx; margin-right: 20rpx; margin-top: 20rpx; float: left;
	}
</style>